package com.lshlmy.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liangxiangming
 * @date 2022/08/31
 **/
@RestController
public class KafkaProducer {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @RequestMapping("/send")
    public Object send() {
        //发送功能就一行代码~
        kafkaTemplate.send("test", "key", "test message send~");
        return "成功";
    }
}